<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <p>计数：555555
        <output id="result"></output>
    </p>
    <button onclick="start()">开始工作</button>
    <button onclick="stop()">停止工作</button>
    <button onclick="backstart()">逆向开始工作</button>
    <button onclick="backstop()">逆向停止工作</button>
    <script>
        var i = 1;
        var x;
        var y;
        function add() { document.getElementById("result").innerHTML = i++; console.log(i++) };
        function minus() { document.getElementById("result").innerHTML = i--; console.log(i--) };

        function start() { x = setInterval("add()", 100 )};
        function stop() { clearInterval(x) };
        function backstart() { y = setInterval("minus()", 100 )};
        function backstop() { clearInterval(y) };
    </script>
</body>

</html>